package com.kang.controller;

import com.kang.commons.Result;
import com.kang.Vo.UsersVo;
import com.kang.bean.Box;
import com.kang.dto.UsersDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * @program: photo_fawu
 * @description: 公开使用接口
 * @author: K.faWu
 * @create: 2021-11-22 17:50
 **/
@RestController
@RequestMapping("/public")
public class PublicController {

    @Autowired
    private UserController userController;
    @Autowired
    private NoticeController noticeController;
    @Autowired
    private PhotoController photoController;

    @Autowired
    private BoxController boxController;

    @PostMapping("/public/upload/photo")
    public Result<?> uploadPhoto(@RequestParam MultipartFile file){
        return photoController.upload(file, -1);
    }

    @PostMapping("/box")
    public Result<?> addBox(@RequestBody Box box){
        return boxController.addBox(box);
    }
    @GetMapping("/box")
    public Result<?> getBoxList(){
        return boxController.getList();
    }


    /**
     * 首页展示照片
     */
    @GetMapping("/photo")
    public Result<?> showPhoto(){
        return photoController.showPhoto();
    }

    /**
     * 获取最近五条公告
     */
    @GetMapping("/notice")
    public Result<?> getNewNotice(){
        return noticeController.getNewNotice();
    }

    /*
     * 获取登录用验证码
     */
//    @GetMapping("/user/getLoginCode/{phone}")
//    public Result getLoginCode(@PathVariable String phone){
//        return userController.getLoginCode(phone);
//    }

    /**
     * 登录
     */
    @PostMapping("/user/login")
    public Result<?> login(@RequestBody UsersDto usersDto){
        return userController.login(usersDto);
    }

    /*
     * 注册用户
     */
//    @PostMapping("/user/register")
//    public Result register(@RequestBody UsersVo usersVo){
//        return userController.register(usersVo);
//    }

    /**
     * 上传头像
     */
    @PostMapping("/user/upload")
    public Result<?> upload(@RequestParam MultipartFile file){
        return userController.upload(file);
    }

    /*
     * 发送验证码
     */
//    @GetMapping("/user/register/{phone}")
//    public Result getVerificationCode(@PathVariable String phone){
//        return userController.getVerificationCode(phone);
//    }

}
